Ext.define('Admin.view.organization.OrganizationTreePanel', {
    extend: 'Ext.tree.Panel',
    xtype: 'organization-tree',
    id: 'organization-tree',
    title: '组织结构',

    requires: [
        'Ext.tree.Panel',
        'Ext.grid.Panel',
    ],

    margin: '20',

    useArrows: true,
    rootVisible: false,

    controller: 'organizationViewController',

    viewModel: {
        type: 'organizationViewModel'
    },

    bind: '{organization}',

    columns: [{
            xtype: 'treecolumn',
            text: '组织',
            width: 200,
            sortable: true,
            dataIndex: 'name',
            locked: true
        }, {
            text: '负责人',
            width: 150,
            dataIndex: 'lead',
            sortable: true
        }, {
            text: '人数',
            width: 150,
            dataIndex: 'count',
            sortable: true
        },
        {
            header: '操作',
            text: '操作',
            xtype: 'actioncolumn',
            cls: 'content-column',
            width: 150,
            items: [{
                xtype: 'button',
                iconCls: 'x-fa fa-edit',
                tooltip: '编辑',
                handler: 'onClickOrganizationEditButton'
            }, {
                xtype: 'button',
                iconCls: 'x-fa fa-trash-o',
                tooltip: '删除',
                handler: 'onClickOrganizationDeleteButton'
            }]
        }
    ],

    tbar: Ext.create('Ext.toolbar.Toolbar', {
        items: [{
                text: '添加',
                iconCls: 'x-fa fa-plus',
                listeners: {
                    click: 'onClickOrganizationAddButton'
                }
            },
            '->', {
                iconCls: 'x-fa fa-pie-chart',
                tooltip: '饼形图',
                listeners: {
                    click: 'onClickOrganizationPieButton'
                }
            },
            {
                iconCls: 'x-fa fa-refresh',
                tooltip: '刷新',
                listeners: {
                    click: 'onClickOrganizationRefreshButton'
                }
            }
        ]
    })
});